package com.ruoyi.project.digital.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.digital.domain.TBack;
import com.ruoyi.project.digital.service.ITBackService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 系统背景图Controller
 * 
 * @author ruoyi
 * @date 2023-11-29
 */
@RestController
@RequestMapping("/digital/systemback")
public class TBackController extends BaseController
{
    @Autowired
    private ITBackService tBackService;

    /**
     * 查询系统背景图列表
     */
    @PreAuthorize("@ss.hasPermi('digital:systemback:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBack tBack)
    {
        startPage();
        List<TBack> list = tBackService.selectTBackList(tBack);
        return getDataTable(list);
    }

    /**
     * 导出系统背景图列表
     */
    @PreAuthorize("@ss.hasPermi('digital:systemback:export')")
    @Log(title = "系统背景图", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TBack tBack)
    {
        List<TBack> list = tBackService.selectTBackList(tBack);
        ExcelUtil<TBack> util = new ExcelUtil<TBack>(TBack.class);
        return util.exportExcel(list, "systemback");
    }

    /**
     * 获取系统背景图详细信息
     */
    @PreAuthorize("@ss.hasPermi('digital:systemback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tBackService.selectTBackById(id));
    }

    /**
     * 新增系统背景图
     */
    @PreAuthorize("@ss.hasPermi('digital:systemback:add')")
    @Log(title = "系统背景图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBack tBack)
    {
        return toAjax(tBackService.insertTBack(tBack));
    }

    /**
     * 修改系统背景图
     */
    @PreAuthorize("@ss.hasPermi('digital:systemback:edit')")
    @Log(title = "系统背景图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBack tBack)
    {
        return toAjax(tBackService.updateTBack(tBack));
    }

    /**
     * 删除系统背景图
     */
    @PreAuthorize("@ss.hasPermi('digital:systemback:remove')")
    @Log(title = "系统背景图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tBackService.deleteTBackByIds(ids));
    }
}
